export function getRandomColor() {
  const r = Math.floor(Math.random() * 256)
  const g = Math.floor(Math.random() * 256)
  const b = Math.floor(Math.random() * 256)
  const res = `#${r.toString(16).padStart(2, '0')}${g.toString(16).padStart(2, '0')}${b.toString(16).padStart(2, '0')}`
  return res
}
export function setTextColorBasedOnBrightness(color: any) {
  let r = 0
  let g = 0
  let b = 0

  r = parseInt(color.substr(1, 2), 16)
  g = parseInt(color.substr(3, 2), 16)
  b = parseInt(color.substr(5, 2), 16)

  // 计算亮度
  const brightness = (r * 299 + g * 587 + b * 114) / 1000
  return brightness > 130 ? '#121314' : '#fefefe'
}
